/*          ._
 *            '.			     _______ _______ ___ ___ _______ 
 *     --._     \    .-.		|   |   |_     _|   |   |    ___|
 *         '. .--;  /  |		|       |_|   |_|   |   |    ___|
 *         ,;/ ^  |`\  /.-"".   |___|___|_______|\_____/|_______|	
 *        ;' \  _/   |'    .'          code.google.com/p/as-hive
 *       /    `.;I> /_.--.` )    __
 *      |    .'`  .'( _.Y/`;    /  \__
 *       \_.'---'`   `\  `-/`-. \__/  \__
 *         /_-.`-.._ _/`\  ;-./_/  \__/  \
 *        |   -./  ;.__.'`\  /  \__/  \__/
 *         `--'   (._ _.'`|  \__/  \__/
 *                /     ./ __/  \__/  \
 *           jgs ; `--';'_/  \__/  \__/
 *               `;-,-'/  \__/  \
 *               ,'`   \__/  \__/
 *
 * Copyright 2009 (c) Jovan Alleyne, Peter Nitsch, Brandon Flowers.
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 */

 /**
 * @author	Jovan Alleyne, Peter Nitsch, Brandon Flowers
 * @version	1.0a
 * @since	Flash 9
 */

package org.hive
{
	import flash.display.DisplayObjectContainer;
	import flash.events.EventDispatcher;
	import flash.utils.Dictionary;
	
	import org.hive.managers.*;
	import org.hive.state.State;
	
	/**
	* The Hive class is the application document class and contains global settings.
	*/
	public class Hive extends EventDispatcher
	{ 

		public static var NAME:String = 'Hive State Framework';
		public static var VERSION:String = '1.0a';
		public static var DEBUG_MODE:Boolean = true;
		
		
		//________________________________________________ PROPERTIES

		public var canvas : DisplayObjectContainer;
		public var stateManager : StateManager;
		public var sequenceManager : SequenceManager;
		
		private var __entryState:State;
		
		
		//________________________________________________ CONSTRUCTOR
		
		/**
		* Creates an instance of the Hive framework.
		*/
		public function Hive( canvas:DisplayObjectContainer, entryState:State=null )
		{
			if(Hive.DEBUG_MODE){trace(NAME +" :: "+ VERSION)}
			
			init(canvas, entryState);
		}
		
		private function init(canvas:DisplayObjectContainer, entryState:State):void {
			__entryState = entryState;
			
			this.canvas = canvas;
			stateManager = new StateManager(this);
			sequenceManager = new SequenceManager(this);
		}
		
		
		//________________________________________________ METHODS
		
		public function start():void {
			stateManager.switchState(__entryState);
		}
		
		
		//________________________________________________ PLUGIN MANAGERS
		
		private var __managerLib:Dictionary = new Dictionary(true);
		
		public function registerManager( key:String, manager:Manager ):void {
			__managerLib[key] = manager;
		}
		
		public function getManager( key:String ):Manager 
		{
			return __managerLib[key];
		}
		

	}
}
